{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'jqdatasdk'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "Input \u001b[1;32mIn [1]\u001b[0m, in \u001b[0;36m<cell line: 2>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mdatetime\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m datetime\n\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mjqdatasdk\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mjq\u001b[39;00m\n",
      "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'jqdatasdk'"
     ]
    }
   ],
   "source": [
    "from datetime import datetime\n",
    "import jqdatasdk as jq\n",
    "\n",
    "#jq.auth('15268829004','829004')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "auth success \n"
     ]
    }
   ],
   "source": [
    "jq.auth('15168412235','412235')\n",
    "\n",
    "path = 'F:\\HQData\\industry\\\\'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'total': 1000000, 'spare': 1000000}\n"
     ]
    }
   ],
   "source": [
    "print(jq.get_query_count())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>close</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>money</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-01-05</th>\n",
       "      <td>10.16</td>\n",
       "      <td>10.18</td>\n",
       "      <td>10.35</td>\n",
       "      <td>9.92</td>\n",
       "      <td>450000439.0</td>\n",
       "      <td>4.565388e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-01-06</th>\n",
       "      <td>10.08</td>\n",
       "      <td>10.03</td>\n",
       "      <td>10.42</td>\n",
       "      <td>9.88</td>\n",
       "      <td>340818825.0</td>\n",
       "      <td>3.453446e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-01-07</th>\n",
       "      <td>9.89</td>\n",
       "      <td>9.84</td>\n",
       "      <td>10.06</td>\n",
       "      <td>9.73</td>\n",
       "      <td>267460942.0</td>\n",
       "      <td>2.634796e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-01-08</th>\n",
       "      <td>9.85</td>\n",
       "      <td>9.51</td>\n",
       "      <td>9.90</td>\n",
       "      <td>9.47</td>\n",
       "      <td>221459917.0</td>\n",
       "      <td>2.128003e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-01-09</th>\n",
       "      <td>9.47</td>\n",
       "      <td>9.59</td>\n",
       "      <td>10.09</td>\n",
       "      <td>9.35</td>\n",
       "      <td>394634239.0</td>\n",
       "      <td>3.835378e+09</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open  close   high   low       volume         money\n",
       "2015-01-05  10.16  10.18  10.35  9.92  450000439.0  4.565388e+09\n",
       "2015-01-06  10.08  10.03  10.42  9.88  340818825.0  3.453446e+09\n",
       "2015-01-07   9.89   9.84  10.06  9.73  267460942.0  2.634796e+09\n",
       "2015-01-08   9.85   9.51   9.90  9.47  221459917.0  2.128003e+09\n",
       "2015-01-09   9.47   9.59  10.09  9.35  394634239.0  3.835378e+09"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df =jq.get_price('000001.XSHE', start_date='2015-01-01', end_date='2021-11-08')\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>close</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>money</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-11-02</th>\n",
       "      <td>19.37</td>\n",
       "      <td>18.18</td>\n",
       "      <td>19.49</td>\n",
       "      <td>17.99</td>\n",
       "      <td>199769050.0</td>\n",
       "      <td>3.691356e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-11-03</th>\n",
       "      <td>18.10</td>\n",
       "      <td>18.03</td>\n",
       "      <td>18.24</td>\n",
       "      <td>17.85</td>\n",
       "      <td>111497204.0</td>\n",
       "      <td>2.009325e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-11-04</th>\n",
       "      <td>18.08</td>\n",
       "      <td>17.87</td>\n",
       "      <td>18.10</td>\n",
       "      <td>17.80</td>\n",
       "      <td>98341098.0</td>\n",
       "      <td>1.760672e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-11-05</th>\n",
       "      <td>17.85</td>\n",
       "      <td>17.64</td>\n",
       "      <td>18.00</td>\n",
       "      <td>17.57</td>\n",
       "      <td>109603988.0</td>\n",
       "      <td>1.942416e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-11-08</th>\n",
       "      <td>17.62</td>\n",
       "      <td>17.38</td>\n",
       "      <td>17.81</td>\n",
       "      <td>17.38</td>\n",
       "      <td>114923431.0</td>\n",
       "      <td>2.010842e+09</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open  close   high    low       volume         money\n",
       "2021-11-02  19.37  18.18  19.49  17.99  199769050.0  3.691356e+09\n",
       "2021-11-03  18.10  18.03  18.24  17.85  111497204.0  2.009325e+09\n",
       "2021-11-04  18.08  17.87  18.10  17.80   98341098.0  1.760672e+09\n",
       "2021-11-05  17.85  17.64  18.00  17.57  109603988.0  1.942416e+09\n",
       "2021-11-08  17.62  17.38  17.81  17.38  114923431.0  2.010842e+09"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>code</th>\n",
       "      <th>pe_ratio</th>\n",
       "      <th>turnover_ratio</th>\n",
       "      <th>pb_ratio</th>\n",
       "      <th>ps_ratio</th>\n",
       "      <th>pcf_ratio</th>\n",
       "      <th>capitalization</th>\n",
       "      <th>market_cap</th>\n",
       "      <th>circulating_cap</th>\n",
       "      <th>circulating_market_cap</th>\n",
       "      <th>day</th>\n",
       "      <th>pe_ratio_lyr</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>73458548</td>\n",
       "      <td>000001.XSHE</td>\n",
       "      <td>10.5504</td>\n",
       "      <td>0.4336</td>\n",
       "      <td>1.1799</td>\n",
       "      <td>2.292</td>\n",
       "      <td>-20.5809</td>\n",
       "      <td>1940591.875</td>\n",
       "      <td>3762.8076</td>\n",
       "      <td>1940575.5</td>\n",
       "      <td>3762.7759</td>\n",
       "      <td>2021-11-01</td>\n",
       "      <td>13.0075</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         id         code  pe_ratio  turnover_ratio  pb_ratio  ps_ratio  \\\n",
       "0  73458548  000001.XSHE   10.5504          0.4336    1.1799     2.292   \n",
       "\n",
       "   pcf_ratio  capitalization  market_cap  circulating_cap  \\\n",
       "0   -20.5809     1940591.875   3762.8076        1940575.5   \n",
       "\n",
       "   circulating_market_cap         day  pe_ratio_lyr  \n",
       "0               3762.7759  2021-11-01       13.0075  "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "symbol = '000001.XSHE'\n",
    "q = jq.query(jq.valuation).filter(jq.valuation.code==symbol)\n",
    "dffund = jq.get_fundamentals(q, '2021-11-01') \n",
    "dffund.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "\n",
    "pd.set_option('max_rows', None)\n",
    "\n",
    "\n",
    "\n",
    "path = 'F:\\HQData\\industry\\\\'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>start_date</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>L72</th>\n",
       "      <td>商务服务业</td>\n",
       "      <td>1996-08-29</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>L71</th>\n",
       "      <td>租赁业</td>\n",
       "      <td>1997-01-30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G53</th>\n",
       "      <td>铁路运输业</td>\n",
       "      <td>1998-05-11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G57</th>\n",
       "      <td>管道运输业</td>\n",
       "      <td>1996-11-04</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G56</th>\n",
       "      <td>航空运输业</td>\n",
       "      <td>1997-11-05</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      name start_date\n",
       "L72  商务服务业 1996-08-29\n",
       "L71    租赁业 1997-01-30\n",
       "G53  铁路运输业 1998-05-11\n",
       "G57  管道运输业 1996-11-04\n",
       "G56  航空运输业 1997-11-05"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_industry = jq.get_industries()\n",
    "df_industry.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_industry.to_csv(path+'industry.csv', encoding='utf8')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['000426.XSHE',\n",
       " '000506.XSHE',\n",
       " '000603.XSHE',\n",
       " '000688.XSHE',\n",
       " '000693.XSHE',\n",
       " '000758.XSHE',\n",
       " '000975.XSHE',\n",
       " '002155.XSHE',\n",
       " '600259.XSHG',\n",
       " '600311.XSHG',\n",
       " '600338.XSHG',\n",
       " '600472.XSHG',\n",
       " '600489.XSHG',\n",
       " '600497.XSHG',\n",
       " '600547.XSHG',\n",
       " '600711.XSHG',\n",
       " '600766.XSHG',\n",
       " '600988.XSHG',\n",
       " '601020.XSHG',\n",
       " '601069.XSHG',\n",
       " '601168.XSHG',\n",
       " '601899.XSHG',\n",
       " '601958.XSHG',\n",
       " '603993.XSHG']"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bechmark_date = '2020-12-31'\n",
    "\n",
    "pool = jq.get_industry_stocks('B09', date=bechmark_date)\n",
    "pool"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>code</th>\n",
       "      <th>pe_ratio</th>\n",
       "      <th>market_cap</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>601168.XSHG</td>\n",
       "      <td>12.4400</td>\n",
       "      <td>290.4877</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>000975.XSHE</td>\n",
       "      <td>18.9502</td>\n",
       "      <td>251.0157</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>600711.XSHG</td>\n",
       "      <td>19.5959</td>\n",
       "      <td>252.7345</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>601899.XSHG</td>\n",
       "      <td>20.2449</td>\n",
       "      <td>2680.1499</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>600489.XSHG</td>\n",
       "      <td>21.3793</td>\n",
       "      <td>407.1743</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>000603.XSHE</td>\n",
       "      <td>22.4956</td>\n",
       "      <td>79.5535</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>600497.XSHG</td>\n",
       "      <td>26.4932</td>\n",
       "      <td>237.7633</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>603993.XSHG</td>\n",
       "      <td>27.7221</td>\n",
       "      <td>1185.7983</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>600988.XSHG</td>\n",
       "      <td>32.8249</td>\n",
       "      <td>271.8831</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>002155.XSHE</td>\n",
       "      <td>40.4920</td>\n",
       "      <td>120.5646</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>600338.XSHG</td>\n",
       "      <td>45.4784</td>\n",
       "      <td>262.2869</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>601020.XSHG</td>\n",
       "      <td>46.7611</td>\n",
       "      <td>77.0095</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>601958.XSHG</td>\n",
       "      <td>47.3436</td>\n",
       "      <td>231.0249</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>000688.XSHE</td>\n",
       "      <td>48.8216</td>\n",
       "      <td>104.6323</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>000426.XSHE</td>\n",
       "      <td>64.7045</td>\n",
       "      <td>131.3592</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>000758.XSHE</td>\n",
       "      <td>80.8713</td>\n",
       "      <td>99.2567</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>600259.XSHG</td>\n",
       "      <td>100.8010</td>\n",
       "      <td>146.8570</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>601069.XSHG</td>\n",
       "      <td>298.5903</td>\n",
       "      <td>77.4409</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           code  pe_ratio  market_cap\n",
       "0   601168.XSHG   12.4400    290.4877\n",
       "1   000975.XSHE   18.9502    251.0157\n",
       "2   600711.XSHG   19.5959    252.7345\n",
       "3   601899.XSHG   20.2449   2680.1499\n",
       "4   600489.XSHG   21.3793    407.1743\n",
       "5   000603.XSHE   22.4956     79.5535\n",
       "6   600497.XSHG   26.4932    237.7633\n",
       "7   603993.XSHG   27.7221   1185.7983\n",
       "8   600988.XSHG   32.8249    271.8831\n",
       "9   002155.XSHE   40.4920    120.5646\n",
       "10  600338.XSHG   45.4784    262.2869\n",
       "11  601020.XSHG   46.7611     77.0095\n",
       "12  601958.XSHG   47.3436    231.0249\n",
       "13  000688.XSHE   48.8216    104.6323\n",
       "14  000426.XSHE   64.7045    131.3592\n",
       "15  000758.XSHE   80.8713     99.2567\n",
       "16  600259.XSHG  100.8010    146.8570\n",
       "17  601069.XSHG  298.5903     77.4409"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "q = jq.query(jq.valuation.code, jq.valuation.pe_ratio, jq.valuation.market_cap)\\\n",
    "    .filter(jq.valuation.pe_ratio>0, jq.valuation.code.in_(pool))\\\n",
    ".order_by(jq.valuation.pe_ratio.asc())\n",
    "\n",
    "df = jq.get_fundamentals(q)\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "ename": "Exception",
     "evalue": "get_all_factors 试用权限已到期，如需购买正式权限请联系JQData管理员，微信号：JQData01",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mException\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-20-08204368b313>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mfacstores\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mjq\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_all_factors\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      2\u001b[0m \u001b[0mfacstores\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\jqdatasdk\\utils.py\u001b[0m in \u001b[0;36m_wrapper\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m    254\u001b[0m             \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"run jqdatasdk.auth first\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    255\u001b[0m         \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 256\u001b[1;33m             \u001b[1;32mreturn\u001b[0m \u001b[0mfunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    257\u001b[0m     \u001b[1;32mreturn\u001b[0m \u001b[0m_wrapper\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    258\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\jqdatasdk\\utils.py\u001b[0m in \u001b[0;36mhashable_cached_func\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m    292\u001b[0m                 \u001b[1;32mfor\u001b[0m \u001b[0mk\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mv\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    293\u001b[0m             }\n\u001b[1;32m--> 294\u001b[1;33m             \u001b[1;32mreturn\u001b[0m \u001b[0mcopy\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdeepcopy\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcached_func\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0m_args\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0m_kwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    295\u001b[0m         \u001b[0mhashable_cached_func\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcache_info\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mcached_func\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcache_info\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    296\u001b[0m         \u001b[0mhashable_cached_func\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcache_clear\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mcached_func\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcache_clear\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\jqdatasdk\\utils.py\u001b[0m in \u001b[0;36mfunc_with_serialized_params\u001b[1;34m(*args, **kwargs)\u001b[0m\n\u001b[0;32m    276\u001b[0m             \u001b[0m_args\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mtuple\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mdeserialize\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0marg\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0marg\u001b[0m \u001b[1;32min\u001b[0m \u001b[0margs\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    277\u001b[0m             \u001b[0m_kwargs\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m{\u001b[0m\u001b[0mk\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mdeserialize\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mv\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mk\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mv\u001b[0m \u001b[1;32min\u001b[0m \u001b[0msix\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mviewitems\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 278\u001b[1;33m             \u001b[1;32mreturn\u001b[0m \u001b[0mfunc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0m_args\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0m_kwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    279\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    280\u001b[0m         \u001b[0mcached_func\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mcache\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfunc_with_serialized_params\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\jqdatasdk\\api.py\u001b[0m in \u001b[0;36mget_all_factors\u001b[1;34m()\u001b[0m\n\u001b[0;32m    759\u001b[0m \u001b[1;33m@\u001b[0m\u001b[0mhashable_lru\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmaxsize\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m3\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    760\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mget_all_factors\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 761\u001b[1;33m     \u001b[1;32mreturn\u001b[0m \u001b[0mJQDataClient\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0minstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_all_factors\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m**\u001b[0m\u001b[0mlocals\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    762\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    763\u001b[0m \u001b[1;33m@\u001b[0m\u001b[0massert_auth\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\jqdatasdk\\client.py\u001b[0m in \u001b[0;36m<lambda>\u001b[1;34m(**kwargs)\u001b[0m\n\u001b[0;32m    281\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    282\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0m__getattr__\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmethod\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 283\u001b[1;33m         \u001b[1;32mreturn\u001b[0m \u001b[1;32mlambda\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmethod\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    284\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    285\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0mget_data_api_url\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\site-packages\\jqdatasdk\\client.py\u001b[0m in \u001b[0;36m__call__\u001b[1;34m(self, method, **kwargs)\u001b[0m\n\u001b[0;32m    276\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0mresult\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    277\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0merr\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mException\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 278\u001b[1;33m                 \u001b[1;32mraise\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    279\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    280\u001b[0m         \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mconvert_message\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mresult\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mException\u001b[0m: get_all_factors 试用权限已到期，如需购买正式权限请联系JQData管理员，微信号：JQData01"
     ]
    }
   ],
   "source": [
    "facstores = jq.get_all_factors()\n",
    "facstores"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'total': 1000000, 'spare': 998201}\n"
     ]
    }
   ],
   "source": [
    "print(jq.get_query_count())"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
